package com.atguigu.springwebdemo.service;

import com.atguigu.springwebdemo.bean.BaseRegion;
import com.atguigu.springwebdemo.bean.Employee;
import com.atguigu.springwebdemo.mappers.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Smexy on 2022/9/7
 *
 *      遵循公司的业务规范，一般需求文档上有。
 *
 *      @Service: 标识当前类是一个业务模型。如果容器扫描到这个注解所标识的类，自动创建一个单例对象
 */
@Service
public class EmployeeServiceImpl implements EmployeeService
{

    @Autowired
    private EmployeeMapper employeeMapper;


    @Override
    public Employee getEmployeeById(Integer id) {

        System.out.println("查询之前先做什么...");

        Employee employee = employeeMapper.getEmployeeById(id);

        System.out.println("查询之后再做什么...");

        return employee;
    }

    @Override
    public void insertEmployee(Employee employee) {

        System.out.println("插入之前先做什么...");

        employeeMapper.insertEmployee(employee);

        System.out.println("插入之后再做什么...");

    }

    @Override
    public void deleteEmployeeById(Integer id) {

        System.out.println("删除之前先做什么...");

        employeeMapper.deleteEmployeeById(id);

        System.out.println("删除之后再做什么...");
    }

    @Override
    public void updateEmployee(Employee employee) {

        System.out.println("更新之前先做什么...");

        employeeMapper.updateEmployee(employee);

        System.out.println("更新之后再做什么...");

    }

    @Override
    public List<Employee> getAll() {

        System.out.println("查询之前先做什么...");

        List<Employee> all = employeeMapper.getAll();

        System.out.println("查询之后再做什么...");

        return all;
    }

    @Override
    public List<BaseRegion> getRegions() {

        System.out.println("查询之前先做什么...");

        List<BaseRegion> regions = employeeMapper.getRegions();

        System.out.println("查询之后再做什么...");

        return regions;
    }
}
